package constant.milk.cashbook.select;

import java.util.ArrayList;
import java.util.Calendar;

import constant.milk.cashbook.R;
import constant.milk.cashbook.SuperActivity;
import constant.milk.cashbook.asset.MemoActivity;
import constant.milk.cashbook.bean.BankData;
import constant.milk.cashbook.bean.CategoryMainData;
import constant.milk.cashbook.bean.CategorySubData;
import constant.milk.cashbook.bean.CheckData;
import constant.milk.cashbook.bean.CreditData;
import constant.milk.cashbook.bean.GiftData;
import constant.milk.cashbook.bean.PhoneData;
import constant.milk.cashbook.bean.RealData;
import constant.milk.cashbook.category.CategoryMainListActivity;
import constant.milk.cashbook.category.CategorySubListActivity;
import constant.milk.cashbook.database.DBSelectQuery;
import constant.milk.cashbook.main.MainAssetChoiceActivity;
import constant.milk.cashbook.main.MainAssetListActivity;
import constant.milk.cashbook.tip.TipMap;
import constant.milk.cashbook.tip.TipInfoActivity;
import constant.milk.cashbook.util.CalendarActivity;
import constant.milk.cashbook.util.MilkManager;
import constant.milk.cashbook.util.MilkUtil;
import android.app.Activity;
import android.content.Intent;
import android.content.res.AssetManager;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.TextView;

public class SelectMainActivity extends SuperActivity
{
	private static final int DATE1_REQUEST_CODE = 0;
	private static final int DATE2_REQUEST_CODE = 1;
	private static final int TYPE_REQUEST_CODE = 2;
	private static final int ASSET_REQUEST_CODE = 3;
	private static final int NAME_REQUEST_CODE = 4;
	private static final int MAIN_CATEGORY_REQUEST_CODE = 5;
	private static final int SUB_CATEGORY_REQUEST_CODE = 6;
	private static final int MEMO_REQUEST_CODE = 7;
	
	public static final String YEAR1_DATA = "YEAR1_DATA";
	public static final String MONTH1_DATA = "MONTH1_DATA";
	public static final String DAY1_DATA = "DAY1_DATA";
	public static final String YEAR2_DATA = "YEAR2_DATA";
	public static final String MONTH2_DATA = "MONTH2_DATA";
	public static final String DAY2_DATA = "DAY2_DATA";
	public static final String TYPE_FLAG = "TYPE_FLAG";
	public static final String KIND_FLAG = "KIND_FLAG";
	public static final String ASSET_FLAG = "ASSET_FLAG";
	public static final String NAME_FLAG = "NAME_FLAG";
	public static final String MAIN_CATAGORY = "MAIN_CATAGORY";
	public static final String SUB_CATAGORY = "SUB_CATAGORY";
	public static final String MEMO_FLAG = "MEMO_FLAG";
	
	private TextView date1TextView;
	private TextView date2TextView;
	
	private View date1View;
	private View date2View;
	
	private View todayView;
	private View oneWeekView;
	private View oneMonthView;
	private View threeMonthView;
	private View halfYearView;
	private View oneYearView;
	
	private View typeView;
	private TextView typeTextView;
	
	private View assetView;
	private TextView assetTextView;
	
	private View assetNameView;
	private TextView assetNameTextView;
	
	private View mainCategoryView;
	private TextView mainCategoryTextView;
	
	private View subCategoryView;
	private TextView subCategoryTextView;
	
	private View memoView;
	private TextView memoTextView;
	
	private Button selectButton;
	
	private int year1;
	private int month1;
	private int day1;
	
	private int year2;
	private int month2;
	private int day2;
	
	private int typeFlag;
	private int kindFlag;
	
	private ArrayList<String> assetNameList;
	private ArrayList<String> categoryMainList;
	private ArrayList<String> categorySubList;
	
	private MilkManager milkManager;
	private DBSelectQuery select;
	
	private boolean allAssetFlag;
	
	private boolean mainCategoryAllFlag;
	private boolean subCategoryAllFlag;
	
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.select_main_activity);
		
		setTitle("조회");
		
		setFindViewId();
		setOnClick();
		setData();
	}

	@Override
	protected void setFindViewId()
	{
		date1TextView = (TextView) findViewById(R.id.selectDate1TextView);
		date2TextView = (TextView) findViewById(R.id.selectDate2TextView);
		
		date1View = findViewById(R.id.selectDate1View);
		date2View = findViewById(R.id.selectDate2View);
		
		todayView = findViewById(R.id.selectTodayView);
		oneWeekView = findViewById(R.id.selectOneWeekView);
		oneMonthView = findViewById(R.id.selectOneMonthView);
		threeMonthView = findViewById(R.id.selectThreeMonthView);
		halfYearView = findViewById(R.id.selectHalfYearView);
		oneYearView = findViewById(R.id.selectOneYearView);
		
		typeView = findViewById(R.id.selectTypeView);
		typeTextView = (TextView) findViewById(R.id.selectTypeTextView);
		
		assetView = findViewById(R.id.selectAssetView);
		assetTextView = (TextView) findViewById(R.id.selectAssetTextView);
		
		assetNameView = findViewById(R.id.selectAssetNameView);
		assetNameTextView = (TextView) findViewById(R.id.selectAssetNameTextView);
		
		mainCategoryView = findViewById(R.id.selectMainCategoryView);
		mainCategoryTextView = (TextView) findViewById(R.id.selectMainCategoryTextView);
		
		subCategoryView = findViewById(R.id.selectSubCategoryView);
		subCategoryTextView = (TextView) findViewById(R.id.selectSubCategoryTextView);
		
		memoView = findViewById(R.id.selectMemoView);
		memoTextView = (TextView) findViewById(R.id.selectMemoTextView);
		
		selectButton = (Button) findViewById(R.id.selectButton);
	}

	@Override
	protected void setOnClick()
	{
		date1View.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				Intent intent = new Intent(superContext, CalendarActivity.class);
				intent.putExtra(CalendarActivity.YEAR, year1);
				intent.putExtra(CalendarActivity.MONTN, month1);
				intent.putExtra(CalendarActivity.DAY, day1);
				startActivityForResult(intent, DATE1_REQUEST_CODE);
			}
		});
		
		date2View.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				Intent intent = new Intent(superContext, CalendarActivity.class);
				intent.putExtra(CalendarActivity.YEAR, year2);
				intent.putExtra(CalendarActivity.MONTN, month2);
				intent.putExtra(CalendarActivity.DAY, day2);
				startActivityForResult(intent, DATE2_REQUEST_CODE);
			}
		});
		
		todayView.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				setToDate();
			}
		});
		
		oneWeekView.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				setOneWeekDate();
			}
		});
		
		oneMonthView.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				setOneMonthDate();
			}
		});
		
		threeMonthView.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				setThreeMonthDate();
			}
		});
		
		halfYearView.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				setHalfYearDate();
			}
		});
		
		oneYearView.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				setOneYearDate();
			}
		});
		
		typeView.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				Intent intent = new Intent(superContext, SelectTypeActivity.class);
				intent.putExtra(SelectTypeActivity.TYPE_DATA, typeTextView.getText().toString());
				startActivityForResult(intent, TYPE_REQUEST_CODE);
			}
		});
		
		assetView.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				Intent intent = new Intent(superContext, MainAssetChoiceActivity.class);
				intent.putExtra(MainAssetChoiceActivity.ASSET_CHOICE_DATA, assetTextView.getText().toString());
				startActivityForResult(intent, ASSET_REQUEST_CODE);
			}
		});
		
		assetNameView.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				Intent intent = new Intent(superContext, MainAssetListActivity.class);
				intent.putExtra(MainAssetListActivity.ASSET_NAME_DATA, assetNameTextView.getText().toString());
				intent.putExtra(MainAssetListActivity.ASSET_LIST_DATA, assetNameList);
				intent.putExtra(MainAssetListActivity.ASSET_ALL_FLAG, allAssetFlag);
				startActivityForResult(intent, NAME_REQUEST_CODE);
			}
		});
		
		mainCategoryView.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				Intent intent = new Intent(superContext, SelectMainCategoryActivity.class);
				intent.putExtra(SelectMainCategoryActivity.CATEGORY_MAIN_ALL_FLAG, mainCategoryAllFlag);
				intent.putExtra(SelectMainCategoryActivity.CATEGORY_MAIN_NAME_DATA, mainCategoryTextView.getText().toString());
				intent.putExtra(SelectMainCategoryActivity.CATEGORY_MAIN_LIST_DATA, categoryMainList);
				startActivityForResult(intent, MAIN_CATEGORY_REQUEST_CODE);
			}
		});
		
		subCategoryView.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				Intent intent = new Intent(superContext, SelectSubCategoryActivity.class);
				intent.putExtra(SelectSubCategoryActivity.CATEGORY_SUB_ALL_FLAG, subCategoryAllFlag);
				intent.putExtra(SelectSubCategoryActivity.CATEGORY_MAIN_NAME_DATA, mainCategoryTextView.getText().toString());
				intent.putExtra(SelectSubCategoryActivity.CATEGORY_SUB_NAME_DATA, subCategoryTextView.getText().toString());
				intent.putExtra(SelectSubCategoryActivity.CATEGORY_SUB_LIST_DATA, categorySubList);
				startActivityForResult(intent, SUB_CATEGORY_REQUEST_CODE);
			}
		});
		
		memoView.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				Intent intent = new Intent(superContext, MemoActivity.class);
				intent.putExtra(MemoActivity.MEMO_DATA, memoTextView.getText().toString());
				startActivityForResult(intent, MEMO_REQUEST_CODE);
			}
		});
		
		selectButton.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				Intent intent = new Intent(superContext, SelectListActivity.class);
				intent.putExtra(YEAR1_DATA, year1);
				intent.putExtra(MONTH1_DATA, month1);
				intent.putExtra(DAY1_DATA, day1);
				intent.putExtra(YEAR2_DATA, year2);
				intent.putExtra(MONTH2_DATA, month2);
				intent.putExtra(DAY2_DATA, day2);
				intent.putExtra(TYPE_FLAG, typeFlag);
				intent.putExtra(KIND_FLAG, kindFlag);
				intent.putExtra(ASSET_FLAG, assetTextView.getText().toString());
				
				if (allAssetFlag)
				{
					intent.putExtra(NAME_FLAG, "");
				}
				else
				{
					intent.putExtra(NAME_FLAG, assetNameTextView.getText().toString());
				}
				
				if (mainCategoryAllFlag)
				{
					intent.putExtra(MAIN_CATAGORY, "");
				}
				else
				{
					intent.putExtra(MAIN_CATAGORY, mainCategoryTextView.getText().toString());
				}
				
				if (subCategoryAllFlag)
				{
					intent.putExtra(SUB_CATAGORY, "");
				}
				else
				{
					intent.putExtra(SUB_CATAGORY, subCategoryTextView.getText().toString());
				}
				
				String memo = memoTextView.getText().toString();
				
				memo = memo.replace(" ", "");
				
				intent.putExtra(MEMO_FLAG, memo);
				
				startActivity(intent);
			}
		});
	}

	@Override
	protected void setData()
	{
		select = new DBSelectQuery(superContext, superDb);
		milkManager = new MilkManager(superContext, superDb);
		
		date1TextView.setTextSize(TEXT_SIZE - 2);
		date2TextView.setTextSize(TEXT_SIZE - 2);
		
		setToDate();
		
		typeTextView.setText(getString(R.string.all));
		setType(typeTextView.getText().toString());
		
		assetTextView.setText(getString(R.string.all));
		
		setAssetNameData(assetTextView.getText().toString());
		
		setCategoryMain();
		mainCategoryAllFlag = true;
		mainCategoryTextView.setText(getString(R.string.all));
		
		setCategorySub();
		subCategoryAllFlag = true;
		subCategoryTextView.setText(getString(R.string.all));
	}
	
	private void setCategoryMain()
	{
		ArrayList<CategoryMainData> list = select.getCategoryMainList();
		
		if (list == null || list.size() < 1)
		{
			mainCategoryTextView.setText("");
			mainCategoryTextView.setHint("카테고리를 추가해주세요.");
			return;
		}
		
		mainCategoryTextView.setText(list.get(0).getName());
		
		categoryMainList = new ArrayList<String>();
		
		for (int i = 0; i < list.size(); i++)
		{
			categoryMainList.add(list.get(i).getName());
		}
	}
	
	private void setCategorySub()
	{
		if (mainCategoryTextView.getText().toString().equals(""))
		{
			subCategoryTextView.setText("");
			subCategoryTextView.setHint("카테고리를 추가해주세요.");
			return;
		}
		
		CategoryMainData data = select.getCategoryMainName(mainCategoryTextView.getText().toString());
		
		ArrayList<CategorySubData> list = select.getCategorySubList(data.getId());
		
		if (list == null || list.size() < 1)
		{
			subCategoryTextView.setText("");
			subCategoryTextView.setHint("카테고리를 추가해주세요.");
			return;
		}
		
		subCategoryTextView.setText(list.get(0).getName());
		
		categorySubList = new ArrayList<String>();
		
		for (int i = 0; i < list.size(); i++)
		{
			categorySubList.add(list.get(i).getName());
		}
	}
	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data)
	{
		super.onActivityResult(requestCode, resultCode, data);
		
		if (resultCode != Activity.RESULT_OK)
		{
			return;
		}
		
		if (requestCode == DATE1_REQUEST_CODE)
		{
			Calendar cal = Calendar.getInstance();
			int tyear1 = data.getIntExtra(CalendarActivity.YEAR, cal.get(Calendar.YEAR));
			int tmonth1 = data.getIntExtra(CalendarActivity.MONTN, cal.get(Calendar.MONTH));
			int tday1 = data.getIntExtra(CalendarActivity.DAY, cal.get(Calendar.DAY_OF_MONTH));
			
			int date1 = Integer.parseInt(MilkUtil.getDateDB(tyear1, tmonth1, tday1));
			int date2 = Integer.parseInt(MilkUtil.getDateDB(year2, month2, day2));
			
			if (!setDateCheck(date1, date2))
			{
				return;
			}
			
			year1 = data.getIntExtra(CalendarActivity.YEAR, cal.get(Calendar.YEAR));
			month1 = data.getIntExtra(CalendarActivity.MONTN, cal.get(Calendar.MONTH));
			day1 = data.getIntExtra(CalendarActivity.DAY, cal.get(Calendar.DAY_OF_MONTH));
			
			setDate1();
		}
		else if (requestCode == DATE2_REQUEST_CODE)
		{
			Calendar cal = Calendar.getInstance();
			int tyear2 = data.getIntExtra(CalendarActivity.YEAR, cal.get(Calendar.YEAR));
			int tmonth2 = data.getIntExtra(CalendarActivity.MONTN, cal.get(Calendar.MONTH));
			int tday2 = data.getIntExtra(CalendarActivity.DAY, cal.get(Calendar.DAY_OF_MONTH));
			
			int date1 = Integer.parseInt(MilkUtil.getDateDB(year1, month1, day1));
			int date2 = Integer.parseInt(MilkUtil.getDateDB(tyear2, tmonth2, tday2));
			
			if (!setDateCheck(date1, date2))
			{
				return;
			}
			
			year2 = data.getIntExtra(CalendarActivity.YEAR, cal.get(Calendar.YEAR));
			month2 = data.getIntExtra(CalendarActivity.MONTN, cal.get(Calendar.MONTH));
			day2 = data.getIntExtra(CalendarActivity.DAY, cal.get(Calendar.DAY_OF_MONTH));
			
			setDate2();
		}
		else if (requestCode == TYPE_REQUEST_CODE)
		{
			String str = data.getStringExtra(SelectTypeActivity.TYPE_DATA);
			
			typeTextView.setText(str);
			setType(str);
		}
		else if (requestCode == ASSET_REQUEST_CODE)
		{
			String str = data.getStringExtra(MainAssetChoiceActivity.ASSET_CHOICE_DATA);
			
			assetTextView.setText(str);
			
			setAssetNameData(str);
		}
		else if (requestCode == NAME_REQUEST_CODE)
		{
			String str = data.getStringExtra(MainAssetListActivity.ASSET_NAME_DATA);
			
			if (str.equals(""))
			{
				assetNameTextView.setText(getString(R.string.all));
				allAssetFlag = true;
			}
			else
			{
				assetNameTextView.setText(str);
				allAssetFlag = false;
			}
		}
		else if (requestCode == MAIN_CATEGORY_REQUEST_CODE)
		{
			String str = data.getStringExtra(CategoryMainListActivity.CATEGORY_MAIN_NAME_DATA);
			
			if (str.equals(""))
			{
				mainCategoryAllFlag = true;
				mainCategoryTextView.setText(getString(R.string.all));
			}
			else
			{
				mainCategoryAllFlag = false;
				mainCategoryTextView.setText(str);
				
				setCategorySub();
			}
			
			subCategoryAllFlag = true;
			subCategoryTextView.setText(getString(R.string.all));
		}
		else if (requestCode == SUB_CATEGORY_REQUEST_CODE)
		{
			String str = data.getStringExtra(CategorySubListActivity.CATEGORY_SUB_NAME_DATA);
			
			if (str.equals(""))
			{
				subCategoryAllFlag = true;
				subCategoryTextView.setText(getString(R.string.all));
			}
			else
			{
				subCategoryAllFlag = false;
				subCategoryTextView.setText(str);
			}
		}
		else if (requestCode == MEMO_REQUEST_CODE)
		{
			String memo = data.getStringExtra(MemoActivity.MEMO_DATA);
			
			memoTextView.setText(memo);
		}
	}
	
	private void setToDate()
	{
		Calendar cal = Calendar.getInstance();
		
		year1 = cal.get(Calendar.YEAR);
		month1 = cal.get(Calendar.MONTH);
		day1 = cal.get(Calendar.DAY_OF_MONTH);
		
		year2 = cal.get(Calendar.YEAR);
		month2 = cal.get(Calendar.MONTH);
		day2 = cal.get(Calendar.DAY_OF_MONTH);
		
		setDate1();
		setDate2();
	}
	
	private void setOneWeekDate()
	{
		Calendar cal = Calendar.getInstance();
		Calendar cal2 = Calendar.getInstance();
		
		cal.add(Calendar.DAY_OF_MONTH, -6);
		year1 = cal.get(Calendar.YEAR);
		month1 = cal.get(Calendar.MONTH);
		day1 = cal.get(Calendar.DAY_OF_MONTH);
		
		year2 = cal2.get(Calendar.YEAR);
		month2 = cal2.get(Calendar.MONTH);
		day2 = cal2.get(Calendar.DAY_OF_MONTH);
		
		setDate1();
		setDate2();
	}
	
	private void setOneMonthDate()
	{
		Calendar cal = Calendar.getInstance();
		Calendar cal2 = Calendar.getInstance();
		
		cal.add(Calendar.MONTH, -1);
		cal.add(Calendar.DAY_OF_MONTH, 1);
		year1 = cal.get(Calendar.YEAR);
		month1 = cal.get(Calendar.MONTH);
		day1 = cal.get(Calendar.DAY_OF_MONTH);
		
		year2 = cal2.get(Calendar.YEAR);
		month2 = cal2.get(Calendar.MONTH);
		day2 = cal2.get(Calendar.DAY_OF_MONTH);
		
		setDate1();
		setDate2();
	}
	
	private void setThreeMonthDate()
	{
		Calendar cal = Calendar.getInstance();
		Calendar cal2 = Calendar.getInstance();
		
		cal.add(Calendar.MONTH, -3);
		cal.add(Calendar.DAY_OF_MONTH, 1);
		year1 = cal.get(Calendar.YEAR);
		month1 = cal.get(Calendar.MONTH);
		day1 = cal.get(Calendar.DAY_OF_MONTH);
		
		year2 = cal2.get(Calendar.YEAR);
		month2 = cal2.get(Calendar.MONTH);
		day2 = cal2.get(Calendar.DAY_OF_MONTH);
		
		setDate1();
		setDate2();
	}
	
	private void setHalfYearDate()
	{
		Calendar cal = Calendar.getInstance();
		Calendar cal2 = Calendar.getInstance();
		
		cal.add(Calendar.MONTH, -6);
		cal.add(Calendar.DAY_OF_MONTH, 1);
		year1 = cal.get(Calendar.YEAR);
		month1 = cal.get(Calendar.MONTH);
		day1 = cal.get(Calendar.DAY_OF_MONTH);
		
		year2 = cal2.get(Calendar.YEAR);
		month2 = cal2.get(Calendar.MONTH);
		day2 = cal2.get(Calendar.DAY_OF_MONTH);
		
		setDate1();
		setDate2();
	}
	
	private void setOneYearDate()
	{
		Calendar cal = Calendar.getInstance();
		Calendar cal2 = Calendar.getInstance();
		
		cal.add(Calendar.YEAR, -1);
		cal.add(Calendar.DAY_OF_MONTH, 1);
		year1 = cal.get(Calendar.YEAR);
		month1 = cal.get(Calendar.MONTH);
		day1 = cal.get(Calendar.DAY_OF_MONTH);
		
		year2 = cal2.get(Calendar.YEAR);
		month2 = cal2.get(Calendar.MONTH);
		day2 = cal2.get(Calendar.DAY_OF_MONTH);
		
		setDate1();
		setDate2();
	}
	
	private void setDate1()
	{
		date1TextView.setText(MilkUtil.getDate(year1, month1+1, day1));
	}
	
	private void setDate2()
	{
		date2TextView.setText(MilkUtil.getDate(year2, month2+1, day2));
	}
	
	private boolean setDateCheck(int date1, int date2)
	{
		if (date1 > date2)
		{
			MilkUtil.showToast(superContext, "앞에 날짜가 뒤에 날짜보다 클수 없습니다.");
			return false;
		}
		
		return true;
	}
	
	private void setType(String type)
	{
		if (type.equals(getString(R.string.out)))
		{
			typeFlag = 0;
			kindFlag = 0;
		}
		else if(type.equals(getString(R.string.in)))
		{
			typeFlag = 1;
			kindFlag = 0;
		}
		else if(type.equals(getString(R.string.move)))
		{
			typeFlag = 2;
			kindFlag = 0;
		}
		else if(type.equals(getString(R.string.creditCardAsset)))
		{
			typeFlag = 4;
			kindFlag = 0;
		}
		else if(type.equals(getString(R.string.phoneAsset)))
		{
			typeFlag = 5;
			kindFlag = 0;
		}
		else if(type.equals(getString(R.string.fanIn)))
		{
			typeFlag = 3;
			kindFlag = 1;
		}
		else if (type.equals(getString(R.string.fanOut)))
		{
			typeFlag = 3;
			kindFlag = 2;
		}
		else if (type.equals(getString(R.string.giftCardOut)))
		{
			typeFlag = 6;
			kindFlag = 0;
		}
		else if (type.equals(getString(R.string.giftCardIn)))
		{
			typeFlag = 7;
			kindFlag = 0;
		}
		else if (type.equals(getString(R.string.all)))
		{
			typeFlag = -1;
			kindFlag = -1;
		}
	}
	
	private void setAssetNameData(String str)
	{
		DBSelectQuery query = new DBSelectQuery(superContext, superDb);
		
		assetNameList = new ArrayList<String>();
		
		if (str.equals(getString(R.string.realAsset)))
		{
			ArrayList<RealData> list = query.getRealList();
			
			if (list == null || list.size() < 1)
			{
				assetNameTextView.setText("");
				assetNameTextView.setHint("현금을 추가해주세요.");
				return;
			}
			
			assetNameTextView.setText(list.get(0).getName());
			
			for (int i = 0; i < list.size(); i++)
			{
				assetNameList.add(list.get(i).getName());
			}
			
			allAssetFlag = false;
		}
		else if (str.equals(getString(R.string.bankAsset)))
		{
			ArrayList<BankData> list = query.getBankList();
			
			if (list == null || list.size() < 1)
			{
				assetNameTextView.setText("");
				assetNameTextView.setHint("통장을 추가해주세요.");
				return;
			}
			
			assetNameTextView.setText(list.get(0).getName());
			
			for (int i = 0; i < list.size(); i++)
			{
				assetNameList.add(list.get(i).getName());
			}
			
			allAssetFlag = false;
		}
		else if (str.equals(getString(R.string.checkCardAsset)))
		{
			ArrayList<CheckData> list = query.getCheckList();
			
			if (list == null || list.size() < 1)
			{
				assetNameTextView.setText("");
				assetNameTextView.setHint("체크카드를 추가해주세요.");
				return;
			}
			
			assetNameTextView.setText(list.get(0).getName());
			
			for (int i = 0; i < list.size(); i++)
			{
				assetNameList.add(list.get(i).getName());
			}
			
			allAssetFlag = false;
		}
		else if (str.equals(getString(R.string.creditCardAsset)))
		{
			ArrayList<CreditData> list = query.getCreditList();
			
			if (list == null || list.size() < 1)
			{
				assetNameTextView.setText("");
				assetNameTextView.setHint("신용카드를 추가해주세요.");
				return;
			}
			
			assetNameTextView.setText(list.get(0).getName());
			
			for (int i = 0; i < list.size(); i++)
			{
				assetNameList.add(list.get(i).getName());
			}
			
			allAssetFlag = false;
		}
		else if (str.equals(getString(R.string.phoneAsset)))
		{
			ArrayList<PhoneData> list = query.getPhoneList();
			
			if (list == null || list.size() < 1)
			{
				assetNameTextView.setText("");
				assetNameTextView.setHint("핸드폰을 추가해주세요.");
				return;
			}
			
			assetNameTextView.setText(list.get(0).getName());
			
			for (int i = 0; i < list.size(); i++)
			{
				assetNameList.add(list.get(i).getName());
			}
			
			allAssetFlag = false;
		}
		else if (str.equals(getString(R.string.giftCardAsset)))
		{
			ArrayList<GiftData> list = query.getGiftList();
			
			if (list == null || list.size() < 1)
			{
				assetNameTextView.setText("");
				assetNameTextView.setHint("상품권을 추가해주세요.");
				return;
			}
			
			assetNameTextView.setText(list.get(0).getName());
			
			for (int i = 0; i < list.size(); i++)
			{
				assetNameList.add(list.get(i).getName());
			}
			
			allAssetFlag = false;
		}
		else if (str.equals(getString(R.string.all)))
		{
			assetNameTextView.setText(getString(R.string.all));
			
			allAssetFlag = true;
		}
	}

	@Override
	protected void tipButton()
	{
		Intent intent = new Intent(superContext, TipInfoActivity.class);
		intent.putExtra(TipInfoActivity.TIP_ID, TipMap.TIP_SELECT);
		startActivity(intent);
	}

}
